﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using AutoMapper;
using contactusform.dataaccess;

namespace contactusform.web
{
    public class AutoMapperConfig
    {
        /// <summary>
        /// Register all mappings defined
        /// </summary>
        public static void RegisterMappings()
        {

            Mapper.CreateMap<ContactViewModel, Contact>()
                .ForMember(t => t.FirstName, m => m.MapFrom(tr => tr.FirstName.ToUpper()))
                .ForMember(t => t.LastName, m => m.MapFrom(tr => tr.LastName.ToUpper()))
                .ForMember(t => t.EmailAddress, m => m.MapFrom(tr => tr.EmailAddress.ToUpper()))
                .ForMember(t => t.Telephone, m => m.MapFrom(tr => string.IsNullOrEmpty(tr.Telephone) ? null : tr.Telephone));

        }

    }

}